﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LittleLove.Base
{
    public class Controls
    {
        /// <summary>
        /// Get all children control by type
        /// </summary>
        /// <param name="control"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IEnumerable<System.Windows.Forms.Control> GetAll(System.Windows.Forms.Control control,
            Type type)
        {
            var controls = control.Controls.Cast<System.Windows.Forms.Control>();

            return controls.SelectMany(ctrl => GetAll(ctrl, type))
                                      .Concat(controls)
                                      .Where(c => c.GetType() == type);
        }

        ///// <summary>
        ///// Design buttons
        ///// </summary>
        //private void updateBtnPosition(Base.CalendarDB.Years currentYear)
        //{
        //    switch (currentYear)
        //    {
        //        case CalendarDB.Years.YEAR_2012:
        //            firstBtnPosition();
        //            break;
        //        case CalendarDB.Years.YEAR_2013:
        //            secondBtnPosition();
        //            break;
        //        case CalendarDB.Years.YEAR_2014:
        //            thirdBtnPosition();
        //            break;
        //        default:
        //            break;
        //    }

        //}

        //private void setupBtnPosition3x4(int firstX, int firstY, int distanceX, int distanceY)
        //{
        //    btnMonth1.Location = new Point(firstX, firstY);
        //    btnMonth2.Location = new Point(firstX + distanceX, firstY);
        //    btnMonth3.Location = new Point(firstX + 2 * distanceX, firstY);
        //    btnMonth4.Location = new Point(firstX + 3 * distanceX, firstY);
        //    btnMonth5.Location = new Point(firstX, firstY + distanceY);
        //    btnMonth6.Location = new Point(firstX + distanceX, firstY + distanceY);
        //    btnMonth7.Location = new Point(firstX + 2 * distanceX, firstY + distanceY);
        //    btnMonth8.Location = new Point(firstX + 3 * distanceX, firstY + distanceY);
        //    btnMonth9.Location = new Point(firstX, firstY + 2 * distanceY);
        //    btnMonth10.Location = new Point(firstX + distanceX, firstY + 2 * distanceY);
        //    btnMonth11.Location = new Point(firstX + 2 * distanceX, firstY + 2 * distanceY);
        //    btnMonth12.Location = new Point(firstX + 3 * distanceX, firstY + 2 * distanceY);
        //}

        //private void setupBtnPosition4x3(int firstX, int firstY, int distanceX, int distanceY)
        //{
        //    btnMonth1.Location = new Point(firstX, firstY);
        //    btnMonth2.Location = new Point(firstX + distanceX, firstY);
        //    btnMonth3.Location = new Point(firstX + 2 * distanceX, firstY);
        //    btnMonth4.Location = new Point(firstX, firstY + distanceY);
        //    btnMonth5.Location = new Point(firstX + distanceX, firstY + distanceY);
        //    btnMonth6.Location = new Point(firstX + 2 * distanceX, firstY + distanceY);
        //    btnMonth7.Location = new Point(firstX, firstY + 2 * distanceY);
        //    btnMonth8.Location = new Point(firstX + distanceX, firstY + 2 * distanceY);
        //    btnMonth9.Location = new Point(firstX + 2 * distanceX, firstY + 2 * distanceY);
        //    btnMonth10.Location = new Point(firstX, firstY + 3 * distanceY);
        //    btnMonth11.Location = new Point(firstX + distanceX, firstY + 3 * distanceY);
        //    btnMonth12.Location = new Point(firstX + 2 * distanceX, firstY + 3 * distanceY);
        //}

        //private void firstBtnPosition()
        //{
        //    int firstX = 180;
        //    int firstY = 45;
        //    int distanceX = 85;
        //    int distanceY = 65;
        //    setupBtnPosition4x3(firstX, firstY, distanceX, distanceY);
        //    btnPrevious.Location = new Point(140, 270);
        //    btnNext.Location = new Point(360, 270);
        //}

        //private void secondBtnPosition()
        //{
        //    int firstX = 54;
        //    int firstY = 84;
        //    int distanceX = 85;
        //    int distanceY = 80;
        //    setupBtnPosition3x4(firstX, firstY, distanceX, distanceY);
        //    btnPrevious.Location = new Point(5, 270);
        //    btnNext.Location = new Point(360, 270);
        //}

        //private void thirdBtnPosition()
        //{
        //    int firstX = 30;
        //    int firstY = 95;
        //    int distanceX = 100;
        //    int distanceY = 80;
        //    setupBtnPosition3x4(firstX, firstY, distanceX, distanceY);
        //    btnPrevious.Location = new Point(5, 270);
        //    btnNext.Location = new Point(360, 270);
        //}
    }
}
